<!DOCTYPE html>
<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">
<head>
<title></title>
<meta charset="utf-8">
<meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<meta name="copyright" content="http://www.appcms.org" />
<link rel="stylesheet" href="skin/base.css" type="text/css" >
<link rel="stylesheet" href="skin/more.css" type="text/css" >
<link rel="stylesheet" href="skin/btn.css" type="text/css" />
<script src="js/zy_control.js"></script>
<script src="js/zy_click.js"></script>
<script src="js/config.js"></script>
<script src="js/common.js"></script>
</head>
<body ontouchstart>
<div id="content" >
	<div class="more">
	    <div class="user_head" id="user_bg">
        	<div class="l" onclick="user_bg();"></div>
            <div class="c">
	      		<div class="avatar" id="avatar"  onclick="user_avatar();"></div>
	      		<div class="nk" id='login'></div>
          	</div>
          	<div class="r" onclick="user_bg();"></div>
	    </div>
	</div>
	
	<div class="more">
    	<div class="item" id="more">
    		
		    <ul>
		      <li ontouchstart="zy_touch('down')" onclick="oauth('sign')"><strong>签到送<script>document.write(l_common['head_txt_integral']);</script></strong><em id="integral"></em></li>
		    </ul>
			
		    <ul>
		      <li ontouchstart="zy_touch('down')" onclick="my_talk()"><strong>我的说说</strong><em id="talk"></em></li>
		      <li ontouchstart="zy_touch('down')" onclick="oauth('user_coupons')"><strong >我的优惠券</strong><em id="coupons"></em></li>
		      <li ontouchstart="zy_touch('down')" onclick="oauth('user_activity')"><strong>我的活动</strong><em id="activity"></em></li>
		    </ul>
			
		    <ul>
			  <li ontouchstart="zy_touch('down')" onclick="oauth('user_activity')"><strong>我的收藏</strong><em id="activity"></em></li>
			  <li ontouchstart="zy_touch('down')" onclick="oauth('user_activity')"><strong>我的评论</strong><em id="activity"></em></li>
		    </ul>
			
		   <ul>
			  <li ontouchstart="zy_touch('down')" onclick="jump('setting')"><strong>设置</strong><em></em></li>
		    </ul>
		
			
    	</div>
	</div>
</div>
</body>
<script>
    zy_init();
	function oklogin(msg){
		var html = '';
		html +='<ul>';
		if(l_models['jifen']==1){
			var txt = localStorage['u_integral']?localStorage['u_integral']:'';
			html +='<li ontouchstart="zy_touch(\'down\')" onclick="oauth(\'sign\')"><strong class="myinfo">签到送'+l_common['head_txt_integral']+'</strong><em id="integral">'+txt+'</em></li>';
		}
		html +='</ul>';
		
		var html_1 = '';
		if(l_models['talk']==1){
			html_1 +='<li ontouchstart="zy_touch(\'down\')" onclick="oauth(\'user_talk\')"><strong class="about">我的说说</strong><em id="talk"></em></li>';
		}
		if(l_models['coupons']==1){
			html_1 +='<li ontouchstart="zy_touch(\'down\')" onclick="oauth(\'user_coupons\')"><strong class="about">我的优惠券</strong><em id="coupons"></em></li>';
		}
		if(l_models['activity']==1){
			html_1 +='<li ontouchstart="zy_touch(\'down\')" onclick="oauth(\'user_activity\')"><strong class="about">我的活动</strong><em id="activity"></em></li>';
		}
		if(html_1!=''){
			html +='<ul>'+html_1+'</ul>';
		}
		
	
		html +='<ul>';
		html +='<li ontouchstart="zy_touch(\'down\')" onclick="oauth(\'sc\')"><strong>我的收藏</strong><em id="sc"></em></li>';
		html +='<li ontouchstart="zy_touch(\'down\')" onclick="oauth(\'pl\')"><strong>我的评论</strong><em id="pl"></em></li>';
		html +='</ul>';
		
		html +='<ul>';
		html +='<li ontouchstart="zy_touch(\'down\')" onclick="jump(\'setting\')"><strong>设置</strong><em></em></li>';
		html +='</ul>';
		
		
		$$('more').innerHTML = html;
		
		
		if(localStorage['u_nick']){
			$$('login').innerHTML='<span id="button" onclick="lout()">'+localStorage['u_nick']+'</span>';
		}else{
			$$('login').innerHTML='<span id="button" onclick="login()">用户登录</span>';
		}
		
		if(localStorage['u_nick']){
			var url = app_path+'index.php?m=iapp&c=user&a=my_info&userid='+localStorage['u_id']+'&acctoken='+localStorage['u_acctoken'];
			uexXmlHttpMgr.open(0,'post',url,"8000");
			uexXmlHttpMgr.send(0);
		}

		if (msg != 'maindata') {
			uexWindow.toast("0", "5", msg, 2000);
		}
	}	
	
	
	function user_avatar(){
		if (!c_l()) {
			localStorage['login'] = 'more';
			gologin();
			return false;
		}
		
		uexWindow.cbActionSheet = function(opId,dataType,data){
			if(dataType==2){
				if(data==0){
					uexImageBrowser.pick();
					uexImageBrowser.cbPick= function (opCode,dataType,data){
						if(dataType==0){
							var photos =data;
							if(photos==''){
								return false;
							}
							var url = app_path+'index.php?m=iapp&c=user&a=avatar&userid='+localStorage['u_id']+'&acctoken='+localStorage['u_acctoken'];
							
							uexXmlHttpMgr.open(99,'post',url,"12000");
							uexXmlHttpMgr.setPostData(99,'1','avatardata',photos);
							uexXmlHttpMgr.send(99);
							uexWindow.toast(1, 5, '头像修改中，请稍候~', 0);
						}
					}
				}
			}
		}
		uexWindow.actionSheet('换个性头像吧！','取消',['更换头像']);
		
	}
	
	function user_bg(){
		if (!c_l()) {
			localStorage['login'] = 'more';
			gologin();
			return false;
		}
		uexWindow.cbActionSheet = function(opId,dataType,data){
			if(dataType==2){
				if(data==0){
					uexImageBrowser.pick();
					uexImageBrowser.cbPick= function (opCode,dataType,data){
						if(dataType==0){
							var photos =data;
							if(photos==''){
								return false;
							}
							var url = app_path+'index.php?m=iapp&c=user&a=set_user_bg&userid='+localStorage['u_id']+'&acctoken='+localStorage['u_acctoken'];
							uexXmlHttpMgr.open(2,'post',url,"12000");
							uexXmlHttpMgr.setPostData(2,'1','photos',photos);
							uexXmlHttpMgr.send(2);
							uexWindow.toast(1, 5, '背景更换中，请稍候~', 0);
						}
					}
				}else if(data==1){
					var url = app_path+'index.php?m=iapp&c=user&a=del_user_bg&userid='+localStorage['u_id']+'&acctoken='+localStorage['u_acctoken'];
					uexXmlHttpMgr.open(3,'post',url,"5000");
					uexXmlHttpMgr.send(3);
					uexWindow.toast(1, 5, '默认背景恢复中，请稍候~', 0);
				}
			}
		}
		uexWindow.actionSheet('可以换个性化背景哦!','取消',['更换背景','恢复默认背景']);
	}
	
	
	function help(){
		uexWindow.open('help', '0', 'help.html', 2, '', '', 0);
	}
	
	function update_cache(){
		var url = app_path + 'index.php?m=iapp&c=app&a=setting';
		uexXmlHttpMgr.open(4, 'post', url, "8000");
		uexXmlHttpMgr.send(4);
	}
	
	function integral(){
		$$('integral').innerHTML=localStorage['u_integral'];
	}
	
	function upgrade(){
		var url = app_path+'index.php?m=iapp&c=app&a=upgrade&ver='+localStorage['version']+'&platform='+localStorage['device'];
		uexXmlHttpMgr.open(1,'post',url,"8000");
		uexXmlHttpMgr.send(1);
	}
	
	function jump(windowname){
		uexWindow.open(windowname, '0', windowname+'.html', 2, '', '', 0);
	}
	
	function oauth(url){
		if (c_l()) {
			if(url == 'user_talk'){
				localStorage['userid'] = localStorage['u_id'];
				localStorage['user_home_nickname'] = localStorage['u_nick'];
			}
			uexWindow.open(url, '0', url+'.html', 2, '', '', 0);
		}else{
			localStorage['login'] = 'more';
			gologin();
		}
	}
	
	function login(){
		localStorage['login'] = 'more';
		openWin('login', 'login.html', '12');
	}
	
	function lout(){
		uexWindow.cbActionSheet = function(opId,dataType,data){
			if(dataType==2){
				if(data==0){
					logout();
					oklogin("退出成功~");
				}
			}
		}
		uexWindow.actionSheet('你确定要退出登录吗？','取消',['退出登录']);
　　	}

	window.uexOnload=function(type){
		if(!type){
			uexWindow.setBounce("1");
			uexWindow.onBounceStateChange=function(t,s){
	　　　　　　	if(t=="0"){
	　　　　　　　　	if(s=="2"){
						oklogin('maindata');
					}
	　　　　　　	}
			}
			
			uexXmlHttpMgr.onData = function(opId, status, data){
				uexXmlHttpMgr.close(opId);
				if (status == 1) {
					$$("content").className = '';
					data=JSON.parse(data);
					uexWindow.closeToast();
					if(opId == 0){
						if (data['success'] == 'OK') {
							if(data['data']['avatar']!=''){
								$$('avatar').innerHTML = '<img src="' + data['data']['avatar'] + '" />';
							}
							if (data['data']['bg'] != '') {
								$$('user_bg').style.backgroundImage = 'url('+data['data']['bg']+')';
							}
							
							if (data['data']['praise'] != '') {
								$$('user_praise').innerHTML = data['data']['praise'];
							}
							
							$$('login').innerHTML = data['data']['nickname'];
							$$('talk').innerHTML = data['data']['talk'];
							$$('coupons').innerHTML = data['data']['coupons'];
							$$('activity').innerHTML = data['data']['activity'];
						}
					}else if(opId == 2){
						if(data['success'] == 'OK'){
							$$('user_bg').style.backgroundImage= 'url('+data['data']['bg']+')';
							uexWindow.toast("0", "5", '背景修改成功~', 1000);
						}else{
							uexWindow.toast("0", "5", '背景修改失败~', 1000);
						}
					}else if(opId == 3){
						if(data['success'] == 'OK'){
							$$('user_bg').style.backgroundImage= 'url(skin/images/user/user_head_bg.jpg)';
							uexWindow.toast("0", "5", data['msg'], 1000);
						}else{
							uexWindow.toast("0", "5", data['msg'], 1000);
						}
					}else if(opId == 99){
						if(data['success'] == 'OK'){
							$$('avatar').innerHTML = '<img src="' + data['data']['avatar'] + '" />';
							uexWindow.toast("0", "5", '头像修改成功~', 1000);
						}else{
							uexWindow.toast("0", "5", '头像修改失败~', 1000);
						}
					}
					
				}else if (status == -1) {
					uexWindow.toast("0","5",'链接超时，请重试~',2000);
				}
			}
			oklogin('maindata');
		}
	}
    </script>
</html>